home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Univers Mac Interactif 52
/
Univers Mac Interactif - Issue 52.iso
/
JOURNAUX
/
csmp-digest-v3-114 1⁄4
< prev
next >
Wrap
Text File
|
1995-11-13
|
76KB
|
2,052 lines
C.S.M.P. Digest Fri, 29 Sep 95 Volume 3 : Issue 114
Today's Topics:
Balloon help in modeless dialog???
Determining your ports
Disable Shift startup?
Error Strings in Resource file?
How do I change the mouse tracking speed?
How to disable entire menu bar?
How to do continuous sound recording
How to receive an "open" message...
Mac game programming web page
Patching _Launch redux
Pathname generation code?
Three AppleScript Qs (Apple Events)
The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
(pottier@clipper.ens.fr).
The digest is a collection of article threads from the internet newsgroups
comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for
people who read news semi-regularly and want an archive of the discussions.
If you don't know what a newsgroup is, you probably don't have access to
it. Ask your systems administrator(s) for details. If you don't have access
to news, you may still be able to post messages to the group by using a
mail server like anon.penet.fi (mail help@anon.penet.fi for more
information).
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
nef.ens.fr). Article threads are not added to the digest until the last
article added to the thread is at least two weeks old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The digest is officially distributed by two means, by email and ftp.
If you want to receive the digest by mail, send email to listserv@ens.fr
with no subject and one of the following commands as body:
help Sends you a summary of commands
subscribe csmp-digest Your Name Adds you to the mailing list
signoff csmp-digest Removes you from the list
Once you have subscribed, you will automatically receive each new
issue as it is created.
The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
Questions related to the ftp site should be directed to
scott.silver@dartmouth.edu.
-------------------------------------------------------
>From reed@medicine.wustl.edu (Thomas Reed)
Subject: Balloon help in modeless dialog???
Date: Wed, 13 Sep 1995 08:36:29 -0500
Organization: Washington University
I've got a program that had a modal options dialog, and I just tried
modifying the code to make it into a modeless dialog. Everything is
working but one thing -- the balloon help I had set up for the dialog no
longer works.
How do I get my 'hdlg' items to work in a modeless dialog?
Thanks in advance!
-Thomas
=====================================================
Thomas Reed Washington University
reed@visar.wustl.edu Medical School
reed@medicine.wustl.edu Saint Louis, MO
http://medinfo.wustl.edu/~reed
- ---------------------------------------------------
Clothes make the man. Naked people have little or no
influence on society. -- Mark Twain
=====================================================
Opinions posted are not the opinions of Wash. U.
+++++++++++++++++++++++++++
>From rdwells@mmm.com (Richard Wells)
Date: 14 Sep 1995 18:01:49 GMT
Organization: 3M Company
reed@medicine.wustl.edu (Thomas Reed) wrote:
>I've got a program that had a modal options dialog, and I just tried
>modifying the code to make it into a modeless dialog. Everything is
>working but one thing -- the balloon help I had set up for the dialog no
>longer works.
>
>How do I get my 'hdlg' items to work in a modeless dialog?
I'm not positive this will help, but Apple's tech note TB 34
discusses the use of the Help Manager with movable modal
dialogs. I suspect that the same concerns apply to modeless
dialogs.
+++++++++++++++++++++++++++
>From resorcerer@aol.com (Resorcerer)
Date: 15 Sep 1995 04:04:17 -0400
Organization: America Online, Inc. (1-800-827-6364)
You have to use an 'hwin' (a list of windows by title or windowKind) to
attach any 'hdlg' or 'hrct' messages to the non-modal dialog's itemlist.
It sucks, but DialogSelect/IsDialogEvent don't support balloons the way
you'd expect (and the way it's documented in NIM). It sucks worse if
you're non-modal windows have dynamic names.
Trust me on this; when I was adding balloons to Resorcerer's own windows
(nearly all of which are non-modal dialogs), it took me
months of trying to figure out why the help didn't show up. Finally
an Apple DTS engineer (help that did show up :) and I sat down and pinned
the thing down.
All of which is why Resorcerer will alerts you to this problem when you
create an 'hdlg' for a moveable modal dialog window.
Doug McKenna
Mathemaesthetics, Inc.
Developers of Resorcerer
---------------------------
>From dunham@nw.pensee.com (David Dunham)
Subject: Determining your ports
Date: Mon, 25 Sep 1995 14:18:21 -0700
Organization: Pensee Corporation
I'm sure I will find this as soon as I post, but so far I haven't found
any code or Gestalt attributes or whatever to determine what sort of
serial ports a Mac has. Notably, does it have a Printer/Modem port instead
of two separate ports?
(The MacOS SDK has Comm Toolbox files, but no documentation.)
David Dunham Pensee Corporation dunham@nw.pensee.com
Voice/Fax 206 783 7404 http://www.pensee.com/dunham/
"I say we should listen to the customers and give them what they want."
"What they want is better products for free." --Scott Adams
+++++++++++++++++++++++++++
>From oster@netcom.com (David Phillip Oster)
Date: Thu, 28 Sep 1995 18:02:04 GMT
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
In article <dunham-2509951418210001@feather.pensee.com> dunham@nw.pensee.com (David Dunham) writes:
>I'm sure I will find this as soon as I post, but so far I haven't found
>any code or Gestalt attributes or whatever to determine what sort of
>serial ports a Mac has. Notably, does it have a Printer/Modem port instead
>of two separate ports?
Are you the David Dunham who wrote the original "Acta"? I've been a fan
of your work for years. Here is small complete program that is an example
of using the Communications Resource Manager to determine what serial ports
exist on a specific machine:
/* main.c - Using Connection Resource Manager, print all the portnames.
Public domain. By David Phillip Oster
*/
#include <stdio.h>
#include <CRMSerialDevices.h>
#include <CommResources.h>
#define Length(s) ((int) (s)[0])
main()
{
CRMRecPtr crp;
CRMRec crm;
CRMSerialPtr csp;
StringPtr s;
FILE *out;
InitCRM();
crm.qLink = NULL;
crm.qType = crmType;
crm.crmVersion = crmRecVersion;
crm.crmPrivate = 0;
crm.crmReserved = 0;
crm.crmDeviceType = crmSerialDevice;
crm.crmDeviceID = 0;
crm.crmAttributes = 0;
crm.crmStatus = 0;
crm.crmRefCon = 0;
crp = &crm;
if(NULL == (out = fopen("log", "w"))){
return -1;
}
while(NULL != (crp = CRMSearch(crp))){
if(NULL != (csp = (CRMSerialPtr) crp->crmAttributes)){
if(NULL != (s = *csp->inputDriverName)){
fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
}
if(NULL != (s = *csp->outputDriverName)){
fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
}
}
}
return 0;
--
- ------- <mail-to:oster@netcom.com> ----------
Ahh! The thorazine is wearing off and the odinazine is coming on...
+++++++++++++++++++++++++++
>From Alex Rosen <alex@procd.com>
Date: 28 Sep 1995 18:42:53 GMT
Organization: Pro CD, Inc.
In article <dunham-2509951418210001@feather.pensee.com> David Dunham,
dunham@nw.pensee.com writes:
>I'm sure I will find this as soon as I post, but so far I haven't found
>any code or Gestalt attributes or whatever to determine what sort of
>serial ports a Mac has. Notably, does it have a Printer/Modem port instead
>of two separate ports?
Here are a couple of threads I saved from a while ago that might help.
--Alex
- ---------------------------------------------------------------------
- -
Path: sundog.tiac.net!news.kei.com!news.mathworks.com!udel!delmarva.com
!newsfeed.internetmci.com!news.silcom.com!usenet
From: David Shortt <wyatt@wyatt.com>
Newsgroups: comp.sys.mac.programmer.misc
Subject: Re: Serial Ports Communication
Date: 14 Jun 1995 05:36:20 GMT
ted@sophocles.algonet.se (Ted Parnefors) wrote:
>I was hoping someone could had the answer to how i can find the device
>name of a port, when opening it with OpenDevice, from what i've read
>in "inside macintosh" the serial port is "AIn" and "AOut" and the parallell
>port is "BIn" and "BOut", but how do i know the name if i plug in a
>serial port card or user the program portshare over a network ?
>Anyone has any ideas? or is this not a good way of using serial communication
>on the Macintosh? I heard something about using Communication Toolbox,
>but haven't found any info on it, so i guess i'm stuck.
>Thanks in advance,
>
>Ted
>
Some kind soul provided this code example some time ago. I've tweaked
it to work on THINK Pascal, but you should be able to see the gist of
it:
- -------------------------------
program test;
uses
CommResources, CRMSerialDevices;
var
crm: CRMRec;
crp: CRMRecPtr;
csp: CRMSerialPtr;
s: StringHandle;
myErr: OSErr;
begin
ShowText; {tells THINK Pascal to show a default text output window}
myErr := InitCRM;
with crm do begin
qLink := nil;
qType := crmType;
crmVersion := crmRecVersion;
crmPrivate := 0;
crmReserved := 0;
crmDeviceType := crmSerialDevice;
crmDeviceID := 0;
crmStatus := 0;
crmRefCon := 0;
end;
crp := @crm; {get pointer to crm}
repeat
crp := CRMRecPtr(CRMSearch(QElemPtr(crp)));
if crp <> nil then begin
csp := CRMSerialPtr(crp^.crmAttributes);
if csp <> nil then begin {write some stuff}
s := csp^.name;
if s <> nil then
writeln('name: "', s^^, '"');
s := csp^.inputDriverName;
if s <> nil then
writeln('Input driver name: "', s^^, '"');
s := csp^.outputDriverName;
if s <> nil then
writeln('Output driver name: "', s^^, '"');
writeln;
end;
end;
until crp = nil;
repeat
until button;
end.
- ---------------------------------
On my Mac this program produces this output:
- ---------------------------------
name: "Modem Port"
Input driver name: ".AIn"
Output driver name: ".AOut"
name: "Printer Port"
Input driver name: ".BIn"
Output driver name: ".BOut"
- ---------------------------------
Hope this helps.
Dave Shortt
wyatt@wyatt.com
From: h+@metrowerks.com (Jon Watte)
Newsgroups: comp.sys.mac.programmer.misc
Subject: Re: Serial Ports Communication
Date: Thu, 15 Jun 1995 10:38:49 -0500
In article <3rl27i$a8l@sophocles.algonet.se>,
ted@sophocles.algonet.se (Ted Parnefors) wrote:
> Anyone has any ideas? or is this not a good way of using serial communication
> on the Macintosh? I heard something about using Communication Toolbox,
> but haven't found any info on it, so i guess i'm stuck.
Comms Resource Manager.
comp.sys.mac.programmer FAQ: http://www.nada.kth.se/~d88-jwa/mac-faq.html
Cheers,
/ h+
Newsgroups: comp.lang.pascal.mac,comp.sys.mac.programmer.help
Path: sundog.tiac.net!news.kei.com!news.mathworks.com!zombie.ncsc.mil
!news.duke.edu!agate!howland.reston.ans.net!ix.netcom.com!netcom.com!oster
From: oster@netcom.com (David Phillip Oster)
Subject: Re: Serial port names for Hurdler, LineShare, etc?
In article <oylerb-2507952346320001@msp6-8.nas.mr.net>
oylerb@tdkt.skypoint.net (Bill A. Oyler) writes:
>This should be a somewhat simple question: how can I retreive some sort of
>"list" of installed serial ports?
This is small sample program that uses just enough of the Connection
Resource
Manager to do exactly what you want. You get a record containing:
the name to show the user,
the inName, the outName, and an icon.
/* main.c - Using Connection Resource Manager, print all the portnames.
*/
#include <stdio.h>
#include <CRMSerialDevices.h>
#include <CommResources.h>
#define Length(s) ((int) (s)[0])
main()
{
CRMRecPtr crp;
CRMRec crm;
CRMSerialPtr csp;
StringPtr s;
FILE *out;
InitCRM();
crm.qLink = NULL;
crm.qType = crmType;
crm.crmVersion = crmRecVersion;
crm.crmPrivate = 0;
crm.crmReserved = 0;
crm.crmDeviceType = crmSerialDevice;
crm.crmDeviceID = 0;
crm.crmAttributes = 0;
crm.crmStatus = 0;
crm.crmRefCon = 0;
crp = &crm;
if(NULL == (out = fopen("log", "w"))){
return -1;
}
while(NULL != (crp = CRMSearch(crp))){
if(NULL != (csp = (CRMSerialPtr) crp->crmAttributes)){
if(NULL != (s = *csp->inputDriverName)){
fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
}
if(NULL != (s = *csp->outputDriverName)){
fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
}
}
}
return 0;
---------------------------
>From grinch@ns.moran.com (Erik Rose)
Subject: Disable Shift startup?
Date: Sat, 09 Sep 1995 23:20:59 -0400
Organization: Vortex Software
How can I fix an INIT so the shift key on startup won't disable it (other
than stuffing it in the System file, please)? The control panel
BootBlocker seems to accomplish this very nicely. Please help me! Do me a
favor & e-mail your replies. Thanx in advance!!
ÑThe Grinch
+++++++++++++++++++++++++++
>From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
Date: Tue, 12 Sep 1995 14:57:33 +0800
Organization: Underemployed, and loving it!
In article <grinch-0909952320590001@nw33.moran.com>, grinch@ns.moran.com
(Erik Rose) wrote:
>How can I fix an INIT so the shift key on startup won't disable it (other
>than stuffing it in the System file, please)? The control panel
>BootBlocker seems to accomplish this very nicely. Please help me! Do me a
>favor & e-mail your replies. Thanx in advance!!
Delete the 'dbex' resource in the System file. Alternatively make your
INIT some other form of system extension (a script bundle perhaps) that
gets run despite the presence of the shift key.
Share and Enjoy.
--
Quinn "The Eskimo!" "That's it, take me to your secret government
labs and cut me into wafer thin sections."
+++++++++++++++++++++++++++
>From ammon@bert.cs.byu.edu (Ammon J. Skidmore)
Date: 13 Sep 1995 05:43:41 GMT
Organization: Brigham Young University
Erik Rose (grinch@ns.moran.com) wrote:
: How can I fix an INIT so the shift key on startup won't disable it (other
: than stuffing it in the System file, please)? The control panel
: BootBlocker seems to accomplish this very nicely. Please help me! Do me a
: favor & e-mail your replies. Thanx in advance!!
under 7.1+, if you put your INIT into a font suitcase and then put the
suitcase into the Fonts folder, it will run regardless of whether the
SHIFT key is down on startup. No system modifications required!
-Ammon
--
Ammon Skidmore | http://bert.cs.byu.edu/~ammon/ammon.html
Skidperfect Software | http://www.shore.net/~chanson
| ftp://ftp.shore.net/members/chanson
---------------------------
>From Peter Kjersgard <petek>
Subject: Error Strings in Resource file?
Date: 6 Sep 1995 19:42:22 GMT
Organization: Motorola Information Systems Group; Mansfield, MA
The app I am writing has 100+ error messages to display to the user. I
carefully typed them into a STR# resource for the app. Sometimes I have to
add/delete in the middle of the list. Since I reference the strings by their
index, I have to keep updating a separate list of defines that map to the
strings. (a BIG pain!!!)
Is there a better way to reference the strings?
What are the benefits of keeping the strings in the resources fork rather than
in the code itself? Is the string only loaded into memory when referenced, thus
saving memory space by keeping the strings in the resource fork? Or is it
simply to allow the strings to be modified without rebuilding the app?
Thanks,
--Pete
petek@dev.cdx.mot.com
+++++++++++++++++++++++++++
>From kenlong@netcom.com (Ken Long)
Date: Wed, 6 Sep 1995 21:49:26 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Peter Kjersgard (petek) wrote:
: The app I am writing has 100+ error messages to display to the user. I
: carefully typed them into a STR# resource for the app. Sometimes I have to
: add/delete in the middle of the list. Since I reference the strings by their
: index, I have to keep updating a separate list of defines that map to the
: strings. (a BIG pain!!!)
: Is there a better way to reference the strings?
I don't know about referencing, but there are easier ways of dealing with
the resource compilation, itself.
One thing, though, Think C uses a special complied resource for its error
strings. They probably found that it *was* an easier way. Also, it's
not as easy to mess with.
Anyway, 'STR#' resources are easy to work on with a combination of
ResTools 3.0 and McSink (I like the older McSink).
ResTools is an unsupported (the author hasn't had time for Mac's)
resource compiler/decompiler, touted as "the poor man's Rez/DeRez." It
has it's uses and it's shortcomings. (I usually use a program for its
uses and leave its deficiencies to some other program which excells in
those aspects.)
It decompiles 'STR#' resouces into a nice, neat list of one-liners. If
you use McSink, ResTools and a text editor with a good Find/Replace
function, you can "whomp up" a 'STR#' resource - regardless of the number
of entries - in a couple minutes.
Therefore, redoing the list is equally as fast and easy, as well as
relinking code references to it.
If you select only the list of entries, in your ".r file" from within
your text editor, the copy, then open McSink, the list will be there.
Then, hit Command I (indent) and Command N (add line numbers) then
Command A (select all) Command C (duh) and close it, then Command V, you
numbered list will be back in your .r file (or wherever you put it) for
referferencing changed GetIndString (and such) calls.
Another way is use an array of Str255, right in your code, and get it
finalized and THEN make a resource out of it. In this case, instead of
your .r file being something ResTools compiles, you make it a .c file,
and change it from a "resource 'STR#' (128, "Error Strings)" to a type
"Str255[numEntries] = {". You can make your commented-out list entry
numbers with McSink and Find/Replace.
Copy the list EXCEPT for the first entry, open McSink, add indents if it
has none, add line numbers, copy and paste into a new "worksheet" doc.
Put your first entry back at the top of the list. Then find every tab and
change it to a return-tab - there will only be the one indent (TAB) per
line. Now, find every comma-return and change it to comma-TAB-// and you
have your indicator numbers.
I think there has to be a zero entry, whereas your resource will start at
#1 (?). But, for your temporary array, you merely add a dummy 0 entry.
The tags will still be the same.
If, in developing your program, you find that you have to add an entry
mid list, just deactivate "Wrap Around" in the Find/Replace dialog, copy
the list to a worksheet, put the insertion point at the end of the added
line, write "TAB//" and give it the number of the next line, Command F,
find return, replace with space+space1return ( + 1\r) and replace all.
This will do from there on down.
This will inform you of what number to write in the GetIndString call,
without having to retag the whole list.
Later, once you have it finalized, you copy the whole array to worksheet
doc (new, empty) and preprocess. This will strip all the comments out
and you can copy it into ResTools for compilation into the 'STR#' resource.
Then, all that you'll have left to do is change the array references in
your code to the 'STR#' references.
One more way to do it would be to use the SetIndString routine to make
your changes to the 'STR#' resource lines as you go. Temporarily add the
calls to your code wherever you need them and nor mess with ResTools or
McSink - just have a record of what you do in an external file so you can
keep track. Keep a copy of the needed calls which you can copy/paste
into your code as needed. Then, each time you run your resource would be
updated.
In fact, you could make a 'STR#' resource with a predetermined number of
blank entries and just write that resource as you write your program.
SetIndString overwrites an existing line in a 'STR#' resource, but you
could modify it to add a line.
It can be found in the snippets as apple.com.
: What are the benefits of keeping the strings in the resources fork
rather than : in the code itself? Is the string only loaded into memory
when referenced, thus : saving memory space by keeping the strings in the
resource fork? Or is it : simply to allow the strings to be modified
without rebuilding the app?
I know if you build an array you have to provide storage for all its
elements, but I don't know about what you asked. I've seen HUGE arrays
set up in code. Look at NewShuttle - 635 array entries, each with their
allotted type assignments.
I'd say resources are handier, once made. When you say GetIndString and
where in RAM you're putting it (myStr?) you are overwriting what was
there (as I understand it) and the list number just points to the
resource ID and list number and it reads it on the fly. Your next
GetIndString call stores it in the same 255, while being used and until
the next overwrite (do I have this right?). I have some 'STR#' ID's with
as many as 150 entries. In an array, that's 150 Str255's (is it not?).
I just checked and I was at least partly right - the rest I need to read
up on. GetIndString does copy the tagged line into an existing area
"theString," of the call) so you are only using one Str255 at any given time.
-Ken-
+++++++++++++++++++++++++++
>From tulip@tiac.net (Ed Anson)
Date: Wed, 06 Sep 1995 20:36:54 -0400
Organization: Tulip Software
In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
> The app I am writing has 100+ error messages to display to the user. I
> carefully typed them into a STR# resource for the app. Sometimes I have to
> add/delete in the middle of the list. Since I reference the strings by their
> index, I have to keep updating a separate list of defines that map to the
> strings. (a BIG pain!!!)
>
> Is there a better way to reference the strings?
There are two solutions to this problem. I have used both:
1. When you delete a string, replace it with an empty string and
abandon the slot.
2. Use an enum instead of a list of defines. Deleting a symbol from the
enum automatically adjusts the values of the others.
> What are the benefits of keeping the strings in the resources fork rather than
> in the code itself? Is the string only loaded into memory when
referenced, thus
> saving memory space by keeping the strings in the resource fork? Or is it
> simply to allow the strings to be modified without rebuilding the app?
The usual reason is to facilitate localization (translation) to another
language. Any string that can be viewed by the user should be in a
resource. That way translation can be done without access to the source
code.
It also opens up ways for sophisticated users to do interesting hacks :)
- --------------------
Ed Anson MediaTree: multimedia outline editor & catalog
Tulip Software
Andover, MA 01810 For details, check out my WWW page:
U.S.A. <http://www.tiac.net/users/tulip/home.html>
+++++++++++++++++++++++++++
>From shopsinm@interport.net (shopsinm)
Date: 7 Sep 1995 01:50:40 GMT
Organization: Quill Program
In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
>The app I am writing has 100+ error messages to display to the user. I
>carefully typed them into a STR# resource for the app. Sometimes I have to
>add/delete in the middle of the list. Since I reference the strings by their
>index, I have to keep updating a separate list of defines that map to the
>strings. (a BIG pain!!!)
>
>Is there a better way to reference the strings?
>
>What are the benefits of keeping the strings in the resources fork rather than
>in the code itself? Is the string only loaded into memory when referenced, thus
>saving memory space by keeping the strings in the resource fork? Or is it
>simply to allow the strings to be modified without rebuilding the app?
I have a slightly dumber way of storing error strings that might help
you. For my code I store each error as a STR resource. This means that
if I eliminate some code I just delete the error strings and place new
ones. The only problem with my sceme is that a very large program (i.e.
500+ resources) would become very slow because each of my errors is a
seperate resource. I don't save my error strings in code because I might
have to change them later. I don't want to dig through everything &
recompile just to fix a spelling error.
Mike
--
Michael Falk Shopsin
shopsinm@interport.net
"If it's not on fire then it's a software problem."
+++++++++++++++++++++++++++
>From Darren Giles <mars@netcom.com>
Date: Thu, 7 Sep 1995 08:59:05 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
In article <42ktiu$k4d@prospero.dev.cdx.mot.com> Peter Kjersgard, petek
writes:
>What are the benefits of keeping the strings in the resources fork rather than
>in the code itself
Among other things, if you're going to do a fat application, this
prevents you
from having two copies of the strings. Add up all the strings in your app
that can be put into resources, and you may find this to be a substantial
savings.
- Darren
==========================================================================
Darren Giles, Technical Director mars@netcom.com
Terran Interactive http://www.terran-int.com
+++++++++++++++++++++++++++
>From DaveZ@mailbag.com (David B. Zwiefelhofer)
Date: Thu, 07 Sep 1995 11:34:24 -0500
Organization: Utility Reduction Specialists, Inc.
In article <shopsinm-0609952154450001@shopsinm.port.net>,
shopsinm@interport.net (shopsinm) wrote:
> In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard
<petek> wrote:
>
> >The app I am writing has 100+ error messages to display to the user. I
> >carefully typed them into a STR# resource for the app. Sometimes I have to
> >add/delete in the middle of the list. Since I reference the strings by their
> >index, I have to keep updating a separate list of defines that map to the
> >strings. (a BIG pain!!!)
> >
> >Is there a better way to reference the strings?
> >
> >What are the benefits of keeping the strings in the resources fork
rather than
> >in the code itself? Is the string only loaded into memory when
referenced, thus
> >saving memory space by keeping the strings in the resource fork? Or is it
> >simply to allow the strings to be modified without rebuilding the app?
>
> I have a slightly dumber way of storing error strings that might help
> you. For my code I store each error as a STR resource. This means that
> if I eliminate some code I just delete the error strings and place new
> ones. The only problem with my sceme is that a very large program (i.e.
> 500+ resources) would become very slow because each of my errors is a
> seperate resource. I don't save my error strings in code because I might
> have to change them later. I don't want to dig through everything &
> recompile just to fix a spelling error.
Personally, I think your way is much better. As far as your program being
slower I really doubt it. I mean how often do you need to access error
messages? Surely no faster than is humanly possible to read them, right?
The other advantage is that it is possible that GetIndString will have to
read in a 32K resource (that's right, the entire STR# resource) just to
access your 50 byte message whereas GetString will only use 50 bytes.
Dave
--
David B. Zwiefelhofer
Utility Reduction Specialists, Inc.
1605 Monroe Street, Suite 110
Madison, WI 53211-2052
(608) 258-8965
(608) 258-9686 FAX
+++++++++++++++++++++++++++
>From tom@jlc.com (Thomas R. Kimpton)
Date: Tue, 12 Sep 1995 15:06:25 -0600
Organization: Jostens Learning Corporation
In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
> The app I am writing has 100+ error messages to display to the user. I
> carefully typed them into a STR# resource for the app. Sometimes I have to
> add/delete in the middle of the list. Since I reference the strings by their
> index, I have to keep updating a separate list of defines that map to the
> strings. (a BIG pain!!!)
>
> Is there a better way to reference the strings?
>
[stuff deleted]
#define myErrorStr1 1
#define myErrorStr2 (myErrorStr1 + 1)
#define myErrorStr3 (myErrorStr2 + 1)
...
If you delete(insert after) the define of myErrorStr2 you need only change the
define for myErrorStr3, and the effect ripples down. Though this has the
side effect that it's hard to know what the define actually is when
looking at it in code.
Tom.
--
Tom Kimpton tom@jlc.com
Jostens Learning Corporation
(801) 223-3228
+++++++++++++++++++++++++++
>From gurgle@apple.com (Pete Gontier)
Date: Tue, 12 Sep 1995 17:52:24 -0800
Organization: Apple Computer, Inc.
In article <tom-1209951506250001@tommac.wicat.com>,
tom@jlc.com (Thomas R. Kimpton) wrote:
> In article <42ktiu$k4d@prospero.dev.cdx.mot.com>,
> Peter Kjersgard <petek> wrote:
>
> > The app I am writing has 100+ error messages to display to the user. I
> > carefully typed them into a STR# resource for the app. Sometimes I have to
> > add/delete in the middle of the list. Since I reference the strings by
> > their index, I have to keep updating a separate list of defines that
> > map to the strings. (a BIG pain!!!)
>
> #define myErrorStr1 1
> #define myErrorStr2 (myErrorStr1 + 1)
> #define myErrorStr3 (myErrorStr2 + 1)
enum
{
kStrIndex_Error_None,
kStrIndex_Error_FileNotFound,
kStrIndex_Error_MemoryExhausted,
kStrIndex_Error_DogcowEnraged
};
If the SubSpace Manager ever ships, you won't have to worry about running
out of memory any more, so you can just triple-click
'kStrIndex_Error_MemoryExhausted' and hit the delete key and all other
values will ripple up. (We will never be able to eliminate the possibility
of the last error in the list.)
--
Pete Gontier // Software reenignE
Macintosh Developer Technical Support // Apple Computer, Inc.
+++++++++++++++++++++++++++
>From stk@berlin.snafu.de (Stefan Kurth)
Date: Wed, 13 Sep 1995 04:27:43 +0200
Organization: none
Thomas R. Kimpton <tom@jlc.com> wrote:
> #define myErrorStr1 1
> #define myErrorStr2 (myErrorStr1 + 1)
> #define myErrorStr3 (myErrorStr2 + 1)
> ...
>
> If you delete(insert after) the define of myErrorStr2 you need only change the
> define for myErrorStr3, and the effect ripples down.
Hmm, I think I would prefer
enum {
myErrorStr1,
myErrorStr2,
myErrorStr3,
...
};
Too bad that this can't be used in files that are included from both C
and Rez.
________________________________________________________________________
Stefan Kurth Berlin, Germany stk@berlin.snafu.de
+++++++++++++++++++++++++++
>From Kevin.R.Boyce@gsfc.nasa.gov (Kevin R. Boyce)
Date: Thu, 14 Sep 1995 13:48:36 -0400
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
In article <gurgle-1209951752240001@mac999.kip.apple.com>,
gurgle@apple.com (Pete Gontier) wrote:
>enum
>{
> kStrIndex_Error_None,
> kStrIndex_Error_FileNotFound,
> kStrIndex_Error_MemoryExhausted,
> kStrIndex_Error_DogcowEnraged
>};
>
>If the SubSpace Manager ever ships, you won't have to worry about running
>out of memory any more, so you can just triple-click
>'kStrIndex_Error_MemoryExhausted' and hit the delete key and all other
>values will ripple up. (We will never be able to eliminate the possibility
>of the last error in the list.)
Well sure, but why bother with an error message in that case. Has
*anybody* ever been in the same room with an enraged dogcow and lived to
tell about it?
Otherwise, good advice. I use enums for all my menu item definitions,
too. Then, as my menus grow ever-longer from version to version, I can
just stick in the new items and they renumber automatically.
--
Kevin Kevin.R.Boyce@gsfc.nasa.gov
"You make a grown man cry." --Mick Jagger
---------------------------
>From Free Library Users <wicomico@shore.intercom.net>
Subject: How do I change the mouse tracking speed?
Date: 12 Sep 1995 18:38:08 GMT
Organization: ICNet, Salisbury, MD
Hi
Do you know how the Mouse control panel does its thing? Does it do some
shady manipulation of a secret system global inconspicuously lurking in
PRAM? Or is the answer right under my nose? If you know the answer or
know how I could find it, I would be most appreciative of any and all
suggestions. Thanks.
Seth Purcell, Mac C++ Programmer for Soliton Software
+++++++++++++++++++++++++++
>From tim@dierks.org (Tim Dierks)
Date: Tue, 12 Sep 1995 23:21:21 +0100
Organization: Best Internet Communications
In article <434k2g$69@shore4.intercom.net>, Free Library Users
<wicomico@shore.intercom.net> wrote:
>Do you know how the Mouse control panel does its thing? Does it do some
>shady manipulation of a secret system global inconspicuously lurking in
>PRAM? Or is the answer right under my nose? If you know the answer or
>know how I could find it, I would be most appreciative of any and all
>suggestions. Thanks.
Check out the Cursor Device Manager, documented in tech note HW 01:
<url:http://www.info.apple.com/dev/technotes/Hardware/hw_01.html>
(by yours truly). The speed is also stored in PRAM and it's done in low
memory if you don't have the CDM. I don't have any info on that with me
right now.
Best,
- Tim Dierks
--
Tim Dierks
tim@dierks.org
---------------------------
>From timmyd@netcom.com (Tim DeBenedictis)
Subject: How to disable entire menu bar?
Date: Sun, 10 Sep 1995 00:32:31 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
I'm writing a generic routine for handling movable modal dialogs. Everything
works fairly well now, but I need some way to disable the entire menu bar,
as ModalDialog() does when it starts up, and then to re-enable the entire
menu bar when it exits. Additionally, my function should be smart enough
to keep the Edit menu active when the movable modal dialog is frontmost. If
anyone out there knows how to do this, or could point me to some sample
code, I'd appreciate it!
-Tim DeBenedictis
timmyd@netcom.com
+++++++++++++++++++++++++++
>From gurgle@apple.com (Pete Gontier)
Date: Tue, 12 Sep 1995 17:31:54 -0800
Organization: Apple Computer, Inc.
In article <timmydDEnyu7.B5z@netcom.com>,
timmyd@netcom.com (Tim DeBenedictis) wrote:
> I'm writing a generic routine for handling movable modal dialogs. Everything
> works fairly well now, but I need some way to disable the entire menu bar,
> as ModalDialog() does when it starts up, and then to re-enable the entire
> menu bar when it exits. Additionally, my function should be smart enough
> to keep the Edit menu active when the movable modal dialog is frontmost.
Disabling the menu bar is easy. Just don't call MenuSelect. :-)
Seriously, though, the structures you would need to do something to a menu
bar directly are quasi-documented (see Inside Mac: Mac Toolbox Essentials
3-97 for the usual warnings about such things). What you need to do to be
clean is keep track of which menus your app has inserted into the menu bar
so you can call...
DisableItem (menuH, 0);
...on each one. Since you are tracking these menus, you can pick and
choose which ones to selectively leave enabled.
--
Pete Gontier // Software reenignE
Macintosh Developer Technical Support // Apple Computer, Inc.
---------------------------
>From poy@ecn.purdue.edu (Alfred L. Poy)
Subject: How to do continuous sound recording
Date: Mon, 11 Sep 1995 16:19:22 -0600
Organization: Purdue University
I'm trying to figure out how to do continuous sound recording. What I
want to do is continuously record a sound and then have access to the
sound data which has already been recorded. I've looked at Apple
source code examples, and while they show how to do double-buffered
playback, they don't show how to do some kind of double-buffered
recording. There is always a skip in recording samples while the
code gears up to call SPRecord again (and play the sound too).
So, how does one accomplish this? Is it possible to create a routine
which will automatically switch between recording buffers when one
is full? Also, can this be implemented as an interrupt routine so
that I can do other tasks in the foreground without having to babysit
the process?
On a related note, I'm trying to implement some FFT routines which
could possibly steal several ticks-worth of processing time. How
would it affect any other interrupt routines if I steal all the cycles?
(What I'm trying to say is I would also like to implement the FFT
routine as an interrupt process as well, to make it "automatic" in
conjunction with the recording process. So can an interrupt routine
itself be interrupted by other interrupt routines?)
Thanks in advance for your help.
Al Poy
Purdue University poy@ecn.purdue.edu
+++++++++++++++++++++++++++
>From dan@apple-iss.iss.nus.sg (Daniel Lau)
Date: Wed, 13 Sep 1995 08:12:32 +0800
Organization: Apple-ISS Research Centre
In article <poy-1109951619220001@192.0.2.1>, poy@ecn.purdue.edu (Alfred L.
Poy) wrote:
> I'm trying to figure out how to do continuous sound recording. What I
> want to do is continuously record a sound and then have access to the
> sound data which has already been recorded. I've looked at Apple
> source code examples, and while they show how to do double-buffered
> playback, they don't show how to do some kind of double-buffered
> recording. There is always a skip in recording samples while the
> code gears up to call SPRecord again (and play the sound too).
>
> So, how does one accomplish this? Is it possible to create a routine
> which will automatically switch between recording buffers when one
> is full? Also, can this be implemented as an interrupt routine so
> that I can do other tasks in the foreground without having to babysit
> the process?
>
You can use the SPBRecord() call to do this. The trick in doing continuous
recording is in the way you set up the sound parameter block. Try this bit
of code (I've left out error-checking for brevity):
SPB gSPB;
long gRefNum;
void
StartContinuousRecording()
{
// Open the default audio input device
SPBOpenDevice( nil, siWritePermission, &gRefNum );
// You might want to set up some characteristics of the audio device
here ie.
// sampling rate, size etc.
gSPB.inRefNum = gRefNum; // Reference to audio input device
gmSPB.count = 0; // Unused for continuous recording
gSPB.milliseconds = 0; // Unused for continuous recording
gSPB.bufferLength = 0; // Unused for continuous recording
gSPB.bufferPtr = nil; // Making this nil allows recording
to continue indefinitely
gSPB.completionRoutine = nil; // No completion routine needed.
gSPB.interruptRoutine = NewSIInterruptProc( InterruptHandler );
gSPB.userLong = 0L; // Or whatever you want
// True for async recording, false for synchronous
SPBRecord( &gSPB, true );
}
Declare an interrupt handler
void InterruptHandler( Ptr deviceBuffer, long deviceBufferSize );
to grab samples from the audio input device's buffer and save it to your
own (big) buffer.
> On a related note, I'm trying to implement some FFT routines which
> could possibly steal several ticks-worth of processing time. How
> would it affect any other interrupt routines if I steal all the cycles?
> (What I'm trying to say is I would also like to implement the FFT
> routine as an interrupt process as well, to make it "automatic" in
> conjunction with the recording process. So can an interrupt routine
> itself be interrupted by other interrupt routines?)
>
You could have your interrupt handler call an FFT function when you've
grabbed enough
samples to work with. I'm not sure how much time you have to play when
the audio input
device interrupts though.
> Thanks in advance for your help.
>
> Al Poy
> Purdue University poy@ecn.purdue.edu
Cheers,
dan
+++++++++++++++++++++++++++
>From chris-b@cs.auckland.ac.nz (chris-b)
Date: Wed, 13 Sep 1995 15:42:37 +1200
Organization: HyperMedia Unit, Comp Sci, Auckland University
In article <poy-1109951619220001@192.0.2.1>, poy@ecn.purdue.edu (Alfred L.
Poy) wrote:
>I'm trying to figure out how to do continuous sound recording. What I
>want to do is continuously record a sound and then have access to the
>sound data which has already been recorded. I've looked at Apple
>source code examples, and while they show how to do double-buffered
>playback, they don't show how to do some kind of double-buffered
>recording. There is always a skip in recording samples while the
>code gears up to call SPRecord again (and play the sound too).
>
>So, how does one accomplish this? Is it possible to create a routine
>which will automatically switch between recording buffers when one
>is full? Also, can this be implemented as an interrupt routine so
>that I can do other tasks in the foreground without having to babysit
>the process?
>
>On a related note, I'm trying to implement some FFT routines which
>could possibly steal several ticks-worth of processing time. How
>would it affect any other interrupt routines if I steal all the cycles?
>(What I'm trying to say is I would also like to implement the FFT
>routine as an interrupt process as well, to make it "automatic" in
>conjunction with the recording process. So can an interrupt routine
>itself be interrupted by other interrupt routines?)
You can do this - note in the SPB structure the "interruptRoutine" field.
This field can contain a UPP to a routine that is called when the Mac's
recording buffer is filled. You can get the size of this buffer by calling
the _SPBGetDeviceInfo trap with a siDeviceBufferInfo query. You'll also
probably need to use many other selectors with _SPBSetDeviceInfo trap to
set the sound input device up as you require.
This is all documented in IM-6 22-59 on ("Recording Sounds Directly From a
Device"). It's probably also in NIM-Sound (or similar).
I don't know if you will be able to do an FFT at interrupt time -
especially from an interrupt service routine.
What I did was call _SPBRecord with SPB.bufferPtr = nil. This causes the
recording to happen until you call _SPBStopRecording. I set up
SPB.interruptRoutine = NewSIInterruptProc(MyInterruptProc). So
MyInterruptProc gets called at the end of each buffer, I do a quick check
of the data and if it looks "interesting", I _BlockMove it into a linked
list of preallocated buffers using the interrupt savvy _Enqueue call.
You could possibly achieve the same thing using deferred tasks...
Email me for more info.
Chris B
- ---------------------------------------------------------------------
NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
Internet: chris-b@cs.auckland.ac.nz
Phone: +64 9 373-7599 x6194
Fax: +64 9 373-7453 Async, therefore I am.
- ---------------------------------------------------------------------
+++++++++++++++++++++++++++
>From fdrake@sunspot.tiac.net (Frank Drake)
Date: 13 Sep 1995 21:08:00 GMT
Organization: The Internet Access Company
In article <dan-1309950812330001@17.127.18.246> dan@apple-iss.iss.nus.sg (Daniel Lau) writes:
[Original message and code deleted]
>
> Declare an interrupt handler
>
> void InterruptHandler( Ptr deviceBuffer, long deviceBufferSize );
>
> to grab samples from the audio input device's buffer and save it to your
> own (big) buffer.
I am accomplishing the same, except I am using the completion routine
and just starting the recording again. By setting the SoundManager
parameter "siContinuous" to 1, I don't get the clicking. However, I am
concerned that this parameter/feature may not be supported on all Mac
sound devices. Can anyone say if I am safe using this or should I use
Dan's method and use an interrupt handler (to avoid the lost data and
clicking that you get when not in continuous mode)?
> > On a related note, I'm trying to implement some FFT routines which
> > could possibly steal several ticks-worth of processing time. How
> > would it affect any other interrupt routines if I steal all the cycles?
> > (What I'm trying to say is I would also like to implement the FFT
> > routine as an interrupt process as well, to make it "automatic" in
> > conjunction with the recording process. So can an interrupt routine
> > itself be interrupted by other interrupt routines?)
> >
> You could have your interrupt handler call an FFT function when you've
> grabbed enough
> samples to work with. I'm not sure how much time you have to play when
> the audio input
> device interrupts though.
I want a very similar result for my application, but I don't know that
you would want to do this during the interrupt. The biggest reason is
that you may not have enough data to make it worth your while. For example,
my mac gets interrupted after sampling 512 bytes of data (I have no idea
how this varies from mac to mac). At 22kHz, you are not getting a lot
of data in that time slice. Perhaps you should collect as much data
as you need for your first FFT, set a flag, and then, back in your
app, do the FFT when that flag is set. I'm not really familiar with the
ins and outs of how you should do things on the mac, but I think you'd
do some polling OUTSIDE your interrupt routine (say, in your programs
event handler?) rather than risking life and limb by doing an FFT during
a SoundManager interrupt.
I'd love to hear some other opinions, though!!! I'm really new to the
Mac and I'm still trying to get a grasp on the way to do some of these
things.
Frank Drake (fdrake@tiac.net)
--
Frank Drake "Jesus saves - and Esposito scores on the rebound!"
InterACTics, Inc. Tel: +1-617-674-0050
420 Bedford Street, Suite 265 FAX: +1-617-674-0125
Lexington, Massachusetts 02173 USA Internet: fdrake@tiac.net
+++++++++++++++++++++++++++
>From nic@crl.com (Guy Nicholas)
Date: 14 Sep 1995 04:19:49 GMT
Organization: CRL Dialup Internet Access
> I want a very similar result for my application, but I don't know that
> you would want to do this during the interrupt. The biggest reason is
> that you may not have enough data to make it worth your while. For example,
> my mac gets interrupted after sampling 512 bytes of data (I have no idea
> how this varies from mac to mac). At 22kHz, you are not getting a lot
> of data in that time slice. Perhaps you should collect as much data
> as you need for your first FFT, set a flag, and then, back in your
> app, do the FFT when that flag is set. I'm not really familiar with the
> ins and outs of how you should do things on the mac, but I think you'd
I understand that another problem with extended "direct to disk" recording
is that most hard drives have a thermal adjustment feature. This means
they recalibrate themselves ever so often due to the disk
growing/shrinking with temperature changes. In order to do this they move
the head somewhere and read or write or something, which interrupts the
steady flow of data. I also understand some drivers have a feature to
lock this recalibration out but you can only hold it off for so long.
Guy
+++++++++++++++++++++++++++
>From poy@ecn.purdue.edu (Alfred L. Poy)
Date: Thu, 14 Sep 1995 10:21:15 -0600
Organization: Purdue University
In article <FDRAKE.95Sep13170800@sunspot.tiac.net>,
fdrake@sunspot.tiac.net (Frank Drake) wrote:
>>> (What I'm trying to say is I would also like to implement the FFT
>>> routine as an interrupt process as well, to make it "automatic" in
>
> I want a very similar result for my application, but I don't know that
> you would want to do this during the interrupt. The biggest reason is
> that you may not have enough data to make it worth your while. For example,
> my mac gets interrupted after sampling 512 bytes of data (I have no idea
> how this varies from mac to mac). At 22kHz, you are not getting a lot
> of data in that time slice.
After thinking it over for a while, I think you're right. Since I'd
like to have 4096 bytes worth of data, I'll have to collect it up
until I have enough. I'm going to first implement the FFT outside of an
interrupt routine. When I get it working, I might attempt to go through
the Deferred Task Manager to have it done somewhat "automatically", as
Chris-b suggested.
Al Poy
Purdue University poy@ecn.purdue.edu
---------------------------
>From chouser@flair13 (Chris Houser)
Subject: How to receive an "open" message...
Date: 4 Sep 95 21:02:04 -0500
Organization: (none)
Hello... I've got a program that is currently launching and running
correctly. I recently added the ability to save and recall files, but I
would like to do this automatically the way a good Mac program should
(i.e. open the file that is double-clicked on in the finder).
Should I be handling this in my event lop somehow, or is it generally
done some other way... Please help me! I've been unable to find any
sample code that contains this...
--Chris Houser
chouser@css.tayloru.edu
+++++++++++++++++++++++++++
>From ntoge@netcom.com (Nobukazu Toge)
Date: Tue, 5 Sep 1995 11:23:47 GMT
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Chris Houser (chouser@flair13) wrote:
> Hello... I've got a program that is currently launching and running
> correctly. I recently added the ability to save and recall files, but I
> would like to do this automatically the way a good Mac program should
> (i.e. open the file that is double-clicked on in the finder).
First, make sure that your app is flagged "high-level event aware".
Then within your event loop, call AEProcessAppleEvent() if the acquired
event->what is kHighLevelEvent. Then AEProcess... calls AppleEvent handler
procs that are to be installed prior to starting the event loop.
This AEProcessAppleEvent() --> handler dispatching is automatic.
What you need to do is, somewhere right after initializing the Mac toolbox
you have to define and install your own adequate AE handler routines with
AEInstallEventHandler() proc. From within those handler routines
you do whatever needs to be done, i.e. open a file, print its content,
etc. Usually a bulk content of such routines can be shared with those
that you'd use for regular actions in response to menu-selections, etc.
So, there won't be much new conding to do, but there are some details
to follow as to exactly how to retrieve the message content of AppleEvents.
Those things are not overwhelming, but a bit too long for here.
Books like Dave Mark's "Ultimate Mac Programming" gives the steps to follow.
If you have a CodeWarrior CD, it has the sample codes fromthis book
and others.
--
Nobu Toge
Internet: ntoge@netcom.com AppleLink: n.toge
AOL : ntoge CompuServe: 76334,650
#include <StandardDisclaimers.h>
+++++++++++++++++++++++++++
>From reed@medicine.wustl.edu (Thomas Reed)
Date: Wed, 06 Sep 1995 08:00:43 -0500
Organization: Washington University
>Should I be handling this in my event lop somehow, or is it generally
>done some other way...
Yes, you need to be using AppleEvents -- if your program is a System 7
program. If you want to support System 6 or both System 6 AND System 7,
then you can do something else, although if you're trying to support both
systems, you should support both ways to do an open.
These days, none of my programs still support System 6, so I'm not as
familiar with that method as I was. But, you can check out CountAppFiles
in Inside Macintosh -- according to the copy of THINK Reference I've got
in front of me, it's in the Segment Loader.
For AppleEvents, here's what you need to do. First, you need to make sure
that the isHighLevelEventAware flag in the SIZE resource of your program
is set.
Second, you need to handle the kHighLevelEvent event type, like this:
void HandleEvent(EventRecord *event)
{
switch (event->what)
{
case mouseDown:
HandleMouseDown(event);
break;
// [...]
case kHighLevelEvent:
HandleAppleEvent(event);
break;
}
}
>From my code, HandleAppleEvent looks like this:
void HandleAppleEvent(EventRecord *event)
{
OSErr myErr;
myErr = AEProcessAppleEvent(event);
if (myErr)
DeathAlert(errProcessAE, myErr);
}
...where DeathAlert is just a custom error handler in my program. This is
all there is to handling an AppleEvent -- sort of. AEProcessAppleEvent
will process the event and determine what kind it is, then look in the
current application's AppleEvent handler table and jump to the appropriate
function. So, you need to set up a handler table, like this:
gOAPPHandler = NewAEEventHandlerProc(MyHandleOAPP);
gODOCHandler = NewAEEventHandlerProc(MyHandleODOC);
gPDOCHandler = NewAEEventHandlerProc(MyHandlePDOC);
gQUITHandler = NewAEEventHandlerProc(MyHandleQUIT);
myErr = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
gOAPPHandler, 0, FALSE);
if (myErr != noErr)
DeathAlert(errInstallAE, myErr);
myErr = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
gODOCHandler, 0, FALSE);
if (myErr != noErr)
DeathAlert(errInstallAE, myErr);
myErr = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
gPDOCHandler, 0, FALSE);
if (myErr != noErr)
DeathAlert(errInstallAE, myErr);
myErr = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
gQUITHandler, 0, FALSE);
if (myErr != noErr)
DeathAlert(errInstallAE, myErr);
...where the gXXXXHandler globals are declared as AEEventHandlerUPP.
So, then the code (from my program) for the handler programs looks like this:
static pascal OSErr MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent
*reply, long handlerRefcon)
{
/* do nothing */
return noErr;
}
static pascal OSErr MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent
*reply, long handlerRefcon)
{
FSSpec myFSS;
AEDescList docList;
OSErr myErr;
long index, itemsInList;
Size actualSize;
AEKeyword keywd;
DescType returnedType;
// get the direct parameter--a descriptor list--and put
// it into docList
myErr = AEGetParamDesc(theAppleEvent, keyDirectObject,
typeAEList, &docList);
if (myErr)
DeathAlert(errParamDescAE, myErr);
// check for missing required parameters
myErr = GotRequiredParams(theAppleEvent);
if (myErr) {
// an error occurred: do the necessary error handling
myErr = AEDisposeDesc(&docList);
return myErr;
}
// now get first descriptor record from the list, coerce
// the returned data to an FSSpec record, and open the
// associated file
// notice that I only call this once -- my program only opens one
// file at a time. You'd need to call this with an index to open
// multiple files.
myErr = AEGetNthPtr(&docList, 1, typeFSS, &keywd, &returnedType,
(Ptr)&myFSS, sizeof(myFSS), &actualSize);
if (myErr)
DeathAlert(errNthPtrAE, myErr);
OpenDocument(&myFSS);
myErr = AEDisposeDesc(&docList);
return noErr;
}
static pascal OSErr MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent
*reply, long handlerRefcon)
{
/* do nothing */
return noErr;
}
static pascal OSErr MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent
*reply, long handlerRefcon)
{
OSErr myErr;
myErr = GotRequiredParams(theAppleEvent);
if (myErr != noErr)
DeathAlert(errParamsAE, myErr);
gQuit = TRUE;
return noErr;
}
Hope this helps!
-Thomas
=====================================================
Thomas Reed Washington University
reed@visar.wustl.edu Medical School
reed@medicine.wustl.edu Saint Louis, MO
http://medinfo.wustl.edu/~reed
- ---------------------------------------------------
Clothes make the man. Naked people have little or no
influence on society. -- Mark Twain
=====================================================
Opinions posted are not the opinions of Wash. U.
---------------------------
>From jgrass@cs.umass.edu (Joshua Grass)
Subject: Mac game programming web page
Date: 14 Sep 1995 17:13:38 GMT
Organization: University of Massachussetts Computer Science Department
Well, I have been spending a large protion of my free time this week
creating a web-page that I think will help a great deal of game
programmers. It is called a HIT(Hierarchical Information Tree)
and it is a collection of cgi-scripts, forms and a simple database
that I hope will be the successor to FAQ's. It is a databse of
information that novices and experts can add to. Novices can ask
questions and experts can check a list of unanswered questions to
see if they can help. What makes it so useful is the fact that
users of the system also create a tree of sub-categories that make
navigation easy. Please come and check it out and let me know
what you think. The web address is:
http://anytime.cs.umass.edu/~jgrass/MGPW/index.html
Joshua
--
If you want to know who you are, | jgrass@cs.umass.edu
it's important to know who you've been. | http://anytime.cs.umass.edu/~jgrass
---------------------------
>From mozart@coos.dartmouth.edu (Michael J. Fromberger)
Subject: Patching _Launch redux
Date: 6 Sep 1995 16:47:48 GMT
Organization: Dartmouth College, Hanover, NH, USA
Hello there,
Many thanks to the kind souls who provided me with copious wisdom on
the subject of how to patch the _Launch trap. Thanks to your
assistance, I've been able to successfully complete my current
project.
For those who might be interested, here is a summary of useful tips:
- The Process Manager installs its own version of the _Launch trap after
the INIT's and CDEV's are done loading. This means you can't just
patch it at INIT time, you have to load something that will do the
patch -after- the Process Manager gets done toying with things.
- One good trick is to patch a -different- trap, which is called after
the Process Manager patches _Launch. _InitGraf was suggested, but if
you do this, you have to be careful to wait for the right time.
_InitGraf is called by many extensions while they are loading, so you
wait 'til the current application name becomes meaningful (something
other than -1L)
- Another way of doing this would be to hook into the low-memory ProcPtr
jGNEFilter, the GetNextEvent/WaitNextEvent filter. This is actually
the stunt I used. This has its own disadvantages, but isn't bad.
If anyone's interested, you can have a copy of the source for the patch
I've written. It's pretty ugly, and most of it's in assembly language,
but it works fairly well for what it's designed to do. If you want a
copy, e-mail me <Michael.Fromberger@Dartmouth.EDU> and I'll fire a copy
your way. I'm developing using Metrowerks CodeWarrior on a 68K.
Once again, gracious thanks to everyone who helped out!
Cheers,
-M
--
Michael J. Fromberger
Consultant, Postmaster Group, Academic Unix Group
Dartmouth College, Hanover, New Hampshire, USA
Sting@Dartmouth.EDU / mozart@coos.dartmouth.edu
It was on analytical algebraic topology of local Euclidean metrization
of infinitely differentiable Riemannian manifolds...Bozhe moj! This
I know...from nothing. -Tom Lehrer
+++++++++++++++++++++++++++
>From gurgle@apple.com (Pete Gontier)
Date: Wed, 06 Sep 1995 12:09:48 -0800
Organization: Apple Computer, Inc.
In article <42kjbk$8th@dartvax.dartmouth.edu>,
mozart@coos.dartmouth.edu (Michael J. Fromberger) wrote:
> - One good trick is to patch a -different- trap, which is called after
> the Process Manager patches _Launch. _InitGraf was suggested, but if
> you do this, you have to be careful to wait for the right time.
> _InitGraf is called by many extensions while they are loading, so you
> wait 'til the current application name becomes meaningful (something
> other than -1L)
Careful. What you want to test is the length byte, the magic value of
which is not -1L but simply -1. I believe the byte immediately after the
length byte is used by the (informally supported) ShowINIT protocol, so
don't do a 32-bit comparison.
--
Pete Gontier // Software reenignE
Macintosh Developer Technical Support // Apple Computer, Inc.
+++++++++++++++++++++++++++
>From mozart@coos.dartmouth.edu (Michael J. Fromberger)
Date: 7 Sep 1995 15:00:16 GMT
Organization: Dartmouth College, Hanover, NH, USA
In <gurgle-0609951209480001@mac207.kip.apple.com> gurgle@apple.com (Pete Gontier) writes:
>Careful. What you want to test is the length byte, the magic value of
>which is not -1L but simply -1. I believe the byte immediately after the
>length byte is used by the (informally supported) ShowINIT protocol, so
>don't do a 32-bit comparison.
I stand corrected...thanks! :)
-M
--
Michael J. Fromberger
Consultant, Postmaster Group, Academic Unix Group
Dartmouth College, Hanover, New Hampshire, USA
Sting@Dartmouth.EDU / mozart@coos.dartmouth.edu
"Half of what he said meant something else,
and the other half didn't mean anything at all!"
-Tom Stoppard
+++++++++++++++++++++++++++
>From kluev@macsimum.gamma.ru (Kluev)
Date: Thu, 7 Sep 95 17:43:11 +0400
Organization: (none)
In article <42kjbk$8th@dartvax.dartmouth.edu>,
mozart@coos.dartmouth.edu (Michael J. Fromberger) wrote:
>Many thanks to the kind souls who provided me with copious wisdom on
>the subject of how to patch the _Launch trap. Thanks to your
>assistance, I've been able to successfully complete my current
>project.
>
>For those who might be interested, here is a summary of useful tips:
>...
>- Another way of doing this would be to hook into the low-memory
ProcPtr
> jGNEFilter, the GetNextEvent/WaitNextEvent filter. This is actually
> the stunt I used. This has its own disadvantages, but isn't bad.
Be carefull, if you are patching Launch this way. Some inits showes
dialogs and cause gne-events to flow *before* process manager starts
its plaing. The example of such an init is "Cache Switch": if you
turn off processor cache on 040 computer next reboot you will see an
alert during init time. If you press the button in this alert using
mouse (not keyboard) gne will fired.
- --------------------------------------------------------------
Michael Kluev kluev@macsimum.gamma.ru
Physics Grad Student Macintosh Programmer
MACsimum Ltd. Moscow, Russia
- --------------------------------------------------------------
+++++++++++++++++++++++++++
>From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
Date: Tue, 12 Sep 1995 14:52:16 +0800
Organization: Underemployed, and loving it!
In article <42kjbk$8th@dartvax.dartmouth.edu>, mozart@coos.dartmouth.edu
(Michael J. Fromberger) wrote:
>Many thanks to the kind souls who provided me with copious wisdom on
>the subject of how to patch the _Launch trap. Thanks to your
>assistance, I've been able to successfully complete my current
>project.
The way I patched _Launch was to tail patch SetTrapAddress looking for
when the Process Manager patches the _Launch trap and then immediately
patch _Launch myself in the tail part of my tail patch. Skanky (see guys,
I've been practising my American :) but it works. Oh and be aware that
System 6 MultiFinder does not call _Launch to launch applications, instead
it calls _OSDispatch with some bizarro undocumented selector.
You can tell I've done this before too (-:
Share and Enjoy.
--
Quinn "The Eskimo!" "That's it, take me to your secret government
labs and cut me into wafer thin sections."
---------------------------
>From dtc@pixar.com (David Catmull)
Subject: Pathname generation code?
Date: 12 Sep 1995 15:35:17 GMT
Organization: Pixar
I'm looking for some code that will find the pathname of a file-
particularly something that will shorten the name if it's too long to fit
in a text box, like:
Disk:...:Folder:File
Please e-mail responses. Thanks in advance.
David Catmull
dtc@pixar.com
+++++++++++++++++++++++++++
>From shaper@scubed.com (Walter Korman)
Date: Wed, 13 Sep 1995 20:58:13 GMT
Organization: S-Cubed division of Maxwell Labs
In article <dtc-1209950836490001@pinky.pixar.com>, dtc@pixar.com (David
Catmull) wrote:
> I'm looking for some code that will find the pathname of a file-
> particularly something that will shorten the name if it's too long to fit
> in a text box, like:
>
> Disk:...:Folder:File
The ellipsis (...) you may need to do yourself; I'm not sure if my
suggestion contains a feature which will do that for you.
My suggestion, then, is to get the "MoreFiles 1.3" library. It's written
by Apple DTS, and contains over 100 functions to work with files. Things
you probably have wanted and not been able to find, like "NameFileSearch",
which will search an entire disk to find an FSSpec for a particular file,
given its name.
The MoreFiles library should be on Apple's FTP or web server somewhere. I
ended up getting it from somewhere in Switzerland, if you can believe
that.
If you're using Eudora or can extract Binhex from your mail, I'll be happy
to mail you an archive of the complete MoreFiles library. It includes a
reference application containing info on all of its functions. Quite well
written, really.
Make sure you compile it with the new Universal Headers 2.1. It won't
compile well with anything else.
Hope this helps!
....................................................................
- Walter Korman * * ** *** ***** ******** <-- Fibonacci Tribbles
shaper@scubed.com
+++++++++++++++++++++++++++
>From ldo@waikato.ac.nz (Lawrence D'Oliveiro)
Date: Thu, 14 Sep 1995 11:54:01 +1200
Organization: University of Waikato
In article <dtc-1209950836490001@pinky.pixar.com>, dtc@pixar.com (David
Catmull) wrote:
>I'm looking for some code that will find the pathname of a file-
>particularly something that will shorten the name if it's too long to fit
>in a text box, like:
>
>Disk:...:Folder:File
IM:Text -- the TruncString and TruncText routines.
---------------------------
>From axel@simplex.nl (Axel Roest)
Subject: Three AppleScript Qs (Apple Events)
Date: Wed, 13 Sep 1995 15:12:01 +0200
Organization: AXEL Development
Hi
I have three trivial (but unresolvable) AppleScript questions:
1) I want to display a window with a status from the script, without having
to press the OK button. Something like a counter for example. I tried the
following:
with timeout of 60 seconds
display dialog counter as string
end timeout
but that waits until the user pressend the button.
At the moment I use a folder in the Finder to display the counter!
2) I have read in MacTech (which I don't have at the moment) that it is
possible to receive events from other applications by type & creator.
Something like
on <<event applsend>> fileList
displayfiles(fileList)
end <<event applsend>>
I can't find any reference to this in the AppleScript Language Guide or
other books I have on my shelf. Is there a document hidden somewhere on my
develop CD or Apple FTP site which explains this?
What I want to do is give another list *back* to the application as a
result, but at the moment I can only return a number.
3) I want to perform a task every minute or so. What I want is something
like this:
repeat
do task
sleep 60 --seconds
end repeat
I cannot find any reference to a sleep, wait, delay function that does
this. At the moment I count the number of ticks in a repeat loop, but that
is kind of cpu time consuming. Any other way to simulate a delay loop?
I hope any gifted programmer out there can give me some solutions!
Axel
________________________
Axel M. Roest | Macintosh developer & UNIX sysadmin
axel@simplex.nl |
+++++++++++++++++++++++++++
>From plsuh@econ.sas.upenn.edu (Paul L. Suh)
Date: Wed, 13 Sep 1995 23:04:46 -0400
Organization: UPenn Grad Econ
In article <AC7CA54196686A4D59@minerva.simplex.nl>, axel@simplex.nl (Axel
Roest) wrote:
>Hi
>I have three trivial (but unresolvable) AppleScript questions:
>
>1) I want to display a window with a status from the script, without
having
>to press the OK button. Something like a counter for example. I tried the
>following:
> with timeout of 60 seconds
> display dialog counter as string
> end timeout
>but that waits until the user pressend the button.
>At the moment I use a folder in the Finder to display the counter!
That's actually not a bad way to do it on the cheap. However, if you want
to display some sort of progress, there is an app called Progress Bar that
does precisely that: it puts up windows under AppleScript control that
have a progress bar and a couple of lines of text. It's available at
<ftp://gaea.kgs.ukans.edu//applescript/scriptableapps/ProgressBar.101.hqx>
>2) I have read in MacTech (which I don't have at the moment) that it is
>possible to receive events from other applications by type & creator.
>Something like
> on <<event applsend>> fileList
> displayfiles(fileList)
> end <<event applsend>>
>
>I can't find any reference to this in the AppleScript Language Guide or
>other books I have on my shelf. Is there a document hidden somewhere on my
>develop CD or Apple FTP site which explains this?
>What I want to do is give another list *back* to the application as a
>result, but at the moment I can only return a number.
I know exactly what you're talking about, and I looked in my books but I
can't find it either. Try subscribing to the MacScrpt mailing list, a
very active and informative source for Mac scripting questions.
>3) I want to perform a task every minute or so. What I want is something
>like this:
> repeat
> do task
> sleep 60 --seconds
> end repeat
>I cannot find any reference to a sleep, wait, delay function that does
>this. At the moment I count the number of ticks in a repeat loop, but that
>is kind of cpu time consuming. Any other way to simulate a delay loop?
This is exactly what idle handlers were invented for.
on idle
-- do stuff
return 60 -- seconds until called again
end idle
Save your script as a stay-open application. The OS will then call the
idle handler every 60 seconds until you quit.
Hope this helps.
--Paul
--
P |\ / S University of Pennsylvania /---------\
| \ / Graduate Economics |/-------\|
| X || . . || My first Macintosh
| / \ Paul L. Suh || \_/ || 512K!
|/ \ D plsuh@econ.sas.upenn.edu || ||
+------ Q |\-------/|
|---------|
|_________|
+++++++++++++++++++++++++++
>From jwbaxter@olympus.net (John W. Baxter)
Date: Thu, 14 Sep 1995 12:25:51 -0700
Organization: Internet for the Olympic Peninsula
In article <AC7CA54196686A4D59@minerva.simplex.nl>, axel@simplex.nl (Axel
Roest) wrote:
> Hi
> I have three trivial (but unresolvable) AppleScript questions:
>
> 1) I want to display a window with a status from the script,
without having
> to press the OK button. Something like a counter for example. I tried the
> following:
> with timeout of 60 seconds
> display dialog counter as string
> end timeout
> but that waits until the user pressend the button.
> At the moment I use a folder in the Finder to display the counter!
Paul Suh has suggested Progress Bar...there is also a newer one without
the bar, called
"Message Window". Probably in the same directory (it *is* on gaea).
Look in
ftp://gaea.kgs.ukans.edu//applescript/scriptableapps/
> 2) I have read in MacTech (which I don't have at the moment) that it is
> possible to receive events from other applications by type & creator.
> Something like
> on <<event applsend>> fileList
> displayfiles(fileList)
> end <<event applsend>>
>
> I can't find any reference to this in the AppleScript Language Guide or
> other books I have on my shelf. Is there a document hidden somewhere on my
> develop CD or Apple FTP site which explains this?
> What I want to do is give another list *back* to the application as a
> result, but at the moment I can only return a number.
There are a few brief words burried in the AppleScript Language Guide.
The 8 characters after the one space after event (assuming you're using
the English dialect) are first the four-character event class, then the
four character event id.
Try this experiment:
on <<event aevtoapp>>
-- the normally "naked" code for your script goes here
end
Because it knows about that event, AppleScript will rewrite the above when
you compile it:
on run
-- the normally "naked" code for your script goes here
end run
The reverse experiment. Compile and save the script (as a compiled script)
display dialog "just testing"
Quit the Script Editor. Remove the display dialog scripting addition from
the Scripting Additions folder.
Start the script editor, and open your saved script (or just double click it).
Note that you get the generic on <<event...>> form for the display dialog.
Drop the scripting addition back into the Scripting Additions folder...it
can execute, and will be rewritten back to the "display dialog" form next
time it is compiled.
You can do similar tricks with <<class abcd>>, which creates a thing of
typeType (or 'type'), with the value 'abcd'.
--John
--
John Baxter Port Ludlow, WA, USA [West shore, Puget Sound]
Bill: what have you done for me lately?
jwbaxter@pt.olympus.net
---------------------------
End of C.S.M.P. Digest
**********************